<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<meta charset="utf-8">
		<title>家家牛</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/resource/weixin/css/mui.min.css">
		<style>
			h5 {
				margin: 5px 7px;
			}
			*{
				margin: 0 0;
			}
		</style>
	</head>
<body>
<div class="mui-slider">
  <div class="mui-slider-group mui-slider-loop">
  	<div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/4.jpg" /></a></div>
    <div class="mui-slider-item"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/1.jpg" /></a></div>
    <div class="mui-slider-item"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/2.jpg" /></a></div>
    <div class="mui-slider-item"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/3.jpg" /></a></div>
    <div class="mui-slider-item"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/4.jpg" /></a></div>
    <div class="mui-slider-item mui-slider-item-duplicate"><a href="#"><img src="${pageContext.request.contextPath}/resource/weixin/image/1.jpg" /></a></div>
  </div>
</div>
<ul class="mui-table-view">
	<c:forEach var="um" items="${ums }">
		<li class="mui-table-view-cell">${um.placeDes }
			<button name="${um.objectId }" type="button" class="mui-btn mui-btn-primary mui-btn-outlined" onclick="unlock(this)">开门</button>
		</li>
	 </c:forEach>
</ul>

<script src="${pageContext.request.contextPath}/resource/assets/js/jquery-2.0.3.min.js"></script>
<script src="${pageContext.request.contextPath}/resource/assets/js/jquery.cookie.js"></script>
<script src="${pageContext.request.contextPath}/resource/weixin/js/mui.min.js"></script>
		<script>
			mui.init({
				swipeBack: true //启用右滑关闭功能
			});
			var gallery = mui('.mui-slider');
			gallery.slider({interval:3000});
			
			function unlock(obj){
				var mid = obj.name;
				var uid = $.cookie("userId");
				$.ajax({
					url:"unlock",
					type:'post',
					data:{mid:mid,uid:uid},
					dataType:'json',
					success:function(data){ 
						if (data == 200) {
							mui.toast('门锁已开');
						}
					},
					error:function(data){
						alert("服务器发生错误，请稍后再试！");
					}
				});
			}
		</script>
	</body>
 </html>